package com.start.config;

import com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;

/**
 * @author Arnold Yand
 * @summary
 * @time 2018/4/5 19:05
 */
@org.springframework.context.annotation.Configuration
public class Configuration {

  /**
   * 使用hessian协议暴露服务相关配置：
   * 1、启用此servlet
   * 2、server.context-path=/user_service 调整为 server.context-path=/
   * 3、服务协议配置如下：
   *  user.service.protocol.name=hessian
   *  user.service.protocol.server=servlet
   *  user.service.protocol.port=11010 （与server.port=11010一致）
   * @return
   */
  @Bean
  public ServletRegistrationBean DruidStatViewServle() {
    ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new DispatcherServlet(), "/*");
    servletRegistrationBean.setName("Hessian_Dispatcher_Servlet");
    servletRegistrationBean.setLoadOnStartup(1);
    return servletRegistrationBean;
  }

}
